
ZamModelViewer.Lol.Texture = function (model, url) {
    var self = this; self.model = model;
    self.url = model.opts.contentPath + "textures/" + url;
    self.texture = null;
    self.load()
};
ZamModelViewer.Lol.Texture.prototype = {
    destroy: function () {
        var self = this, gl = self.model.renderer.context;
        if (self.texture) gl.deleteTexture(self.texture); self.img = null
    },
    load: function () {
        var self = this, gl = self.model.renderer.context;
        (function (self, gl) {
            self.img = new Image; self.img.crossOrigin = ""; self.img.onload = function () {
                self.img.loaded = true;
                self.texture = gl.createTexture();
                gl.bindTexture(gl.TEXTURE_2D, self.texture);
                gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, self.img);
                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
            }; self.img.onerror = function () {
                self.img = null; self.error = true
            }; self.img.src = self.url
        })(self, gl)
    }
}; 